
import Vuex from 'vuex'
import drugStore from './modules/drugStore/index.js'
import course from './modules/course/index.js'

import defaultState from './state/state'
import mutations from './mutations/mutations'
import getters from './getters/getters'
import actions from './actions/actions'

const isDev = process.env.NODE_ENV === 'development'

export default () => {
  const store = new Vuex.Store({
    strict: isDev,
    // namespaced: true,
    state: defaultState,
    mutations,
    getters,
    actions,
    modules: {
      drugStore,
      course
    }
  })
  if (module.hot) {
    module.hot.accept([
      './state/state'
      // './mutations/mutations',
      // './getters/getters',
      // './actions/actions',
      // ['./modules/course/index'],
      // ['./modules/drugStore/index']
    ], () => {
      const newState = require('./state/state')
      // const newMutations = require('./mutations/mutations').default
      // const newGetters = require('./getters/getters').default
      // const newActions = require('./actions/actions').default
      // const newDrugStore = require('./modules/drugStore/index.js').default
      // const newCourse = require('./modules/course/index.js').default
      store.hotUpdate({
        state: newState
        // mutations: newMutations,
        // getters: newGetters,
        // actions: newActions,
        // modules: {
        //   drugStore: newDrugStore,
        //   course: newCourse
        // }
      })
    })
  }
  return store
}
